<html>
  <script>
    async function accessStorage() {
      // Set cookie which persists across restart.
      document.cookie = `persistent=persistent;max-age=3600;` +
          'path=/;SameSite=None;Secure';

      // Set a non-persistent cookie.
      document.cookie = 'session_only=session_only; path=/;' +
          'SameSite=None;Secure';

      // Set a previously unseen cookie which has already expired.
      document.cookie = 'expired=;expires=Thu, 01 Jan 1970 00:00:00 GMT;' +
          'SameSite=None; Secure';

      // Access local storage.
      localStorage.setItem('foo', 'bar');

      try {
        // Third-party context WebSQL is disabled as of M97.
        window.openDatabase('foo', '1.0', 'foo DB', 1024);
      } catch (e) {}

      // Access file system.
      await new Promise(resolve => {
        window.webkitRequestFileSystem(TEMPORARY, 1024, function (fs) {
          fs.root.getFile('foo.txt', { create : true }, fileEntry => {
            fileEntry.createWriter(function (fileWriter) {
              fileWriter.onwriteend = () => resolve();
              let blob = new Blob([1,2,3], { type: 'text/plain' });
              fileWriter.write(blob);
            });
          },
        );
        }, () => resolve());
      });

      // Access service worker.
      await navigator.serviceWorker.register("empty.js");

      // Access cache storage.
      await caches.open('test');

      // Access Indexed DB.
      await new Promise(resolve => {
        let open = indexedDB.open('test');
        open.onupgradeneeded = () => {
          open.result.createObjectStore('store', { keyPath: 'id' });
        }
        open.onsuccess = () => {
          let db = open.result;
          let tx = db.transaction('store', 'readwrite');
          let store = tx.objectStore('store');
          store.put({ id: 42, value: 43 });
          tx.oncomplete = () => {
            db.close();
            resolve();
          };
        }
      });

      return true;
     }
  </script>
  <body>
  </body>
</html>
